from pathlib import Path
import sys

base_path = str(Path(__file__).resolve().parent.parent)
sys.path.append(base_path)
from ai_configs import defalut_ai_config
from main import ai_chat_stream


def on_think_start():
    print("think start --->")


def on_think(think_full_text, think_chunk_text):
    sys.stdout.write(think_chunk_text)
    sys.stdout.flush()


def on_think_end():
    print("think end --->")


def on_receiving(receiving_full_text, receiving_chunk_text):
    sys.stdout.write(receiving_chunk_text)
    sys.stdout.flush()


def on_finish(full_text):
    print("\nfinish: " + full_text)


ai_chat_stream(
    ai_config=defalut_ai_config["deepseek"],
    on_think_start=on_think_start,
    on_think=on_think,
    on_think_end=on_think_end,
    on_receiving=on_receiving,
    on_finish=on_finish,
    histories=[
        {
            "role": "user",
            "content": "请用表格的方式展示过去10年美债利率变化以及当年纳斯达克的涨幅，现在是2025年",
        }
    ],
)
